package com.yb.nowcoder;

/**
 * 字符串
 * toCharArray() // 获得字符串对应的char数组
 * Arrays.sort() // 数组排序
 * Arrays.toString(char[] a) // 数组转成字符串
 * charAt(int x) // 获得某个索引处的字符
 */

/**
 * 牛客网 类名为Main
 * 不要包含package信息
 * hasNext是检查是否有非空字符
 * hasNextLine是检查输入中是否还有linePattern
 */
public class MainTest {

    public static void main(String[] args) {
//        Scanner in = new Scanner(System.in);
//        while (in.hasNextInt()) {//注意while处理多个case
//            int n = in.nextInt();
//            System.out.println(factorial(n));
//        }
        String s = "5s";
        s = s.trim();
        String[] arr = s.split("[^a-zA-Z]+");
        System.out.print(arr.length);
        for (int i=0;i<arr.length;i++){
            System.out.print(arr[i]);
        }
    }

    /**
     * 有n步台阶，一次只能上1步或2步，共有多少种走法。
     * 递归实现
     *
     * @param n
     * @return
     */
    public static int f(int n) {
        if (n <= 2) return n;
        return f(n - 1) + f(n - 2);
    }

    /**
     * 迭代实现
     *
     * @param n
     * @return
     */
    public static int f1(int n) {
        if (n <= 2) {
            return n;
        }
        int first = 1, second = 2, third = 0;
        for (int i = 3; i <= n; i++) {
            third = first + second;
            first = second;
            second = third;
        }
        return third;
    }

    /**
     * 阶乘
     *
     * @param n
     * @return
     */
    public static long factorial(int n) {
        long sum = 1;
        while (n > 0) {
            sum = sum * n--;
        }
        return sum;
    }

    /**
     * 排列
     *
     * @param m
     * @param n
     * @return
     */
    public static long arrangement(int m, int n) {
        return m <= n ? factorial(n) / factorial(n - m) : 0;
    }

    /**
     * 组合
     *
     * @param m
     * @param n
     * @return
     */
    public static long combination(int m, int n) {
        return m <= n ? factorial(n) / (factorial(m) * factorial((n - m))) : 0;
    }

    /**
     * 判断是否为数字
     */
    public static boolean isNum(char c) {
        return Character.isDigit(c);
    }

    /**
     * 判断是否为字母
     * @param c
     * @return
     */
    public static boolean isLetter(char c) {
        return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
    }
}
